#include "widget.h"
#include "ui_widget.h"
#include <QTranslator>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_comboBox_activated(int index)
{
    QTranslator translator;
    switch (index) {
    case 0:
        translator.load("/home/jake/workspace/demo/cxx/qt/internation/Resource/translations/chinese.qm");
        break;
    default:
        translator.load("/home/jake/workspace/demo/cxx/qt/internation/Resource/translations/english.qm");
        break;
    }

    qApp->installTranslator(&translator);
    ui->retranslateUi(this);

    ui->comboBox->setCurrentIndex(index);

    ui->label->setText(tr("Hello world"));

}
